import log from './app/helpers/logger';
import app from './app'
import redisClient from './app/lib/redis';

const port = process.env.PORT || 80;
app
  .listen(port as number)
  .then(async () => {
    log.info('[START] UCToo API ONLINE: ' + port);
    try {
      await redisClient.connect();
    } catch (e) {
      log.info('[REDIS] ' + e);
    }
  })
  .catch((error) =>
    log.error('FAILED TO START API: ' + port + ' Error ' + error)
  );
